<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">姓名</label>
        <div class="layui-input-block">
            <input type="text" name="name" th:value="${admin.name}" maxlength="10" lay-verify="required" lay-reqtext="姓名不能为空" placeholder="请输入姓名" value="" class="layui-input">
<!--            <tip>填写自己管理账号的名称。</tip>-->
        </div>
    </div>

    <input type="hidden" name="id" th:value="${admin.id}">

    <div class="layui-form-item">
        <label class="layui-form-label required">性别</label>
        <div class="layui-input-block">
            <input type="radio" name="gender" value="男" title="男" th:checked="${admin.gender == '男'}">
            <input type="radio" name="gender" value="女" title="女" th:checked="${admin.gender == '女'}">
        </div>
    </div>

<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label required">账号</label>-->
<!--        <div class="layui-input-block">-->
<!--            <input type="text" name="account" readonly th:value="${admin.account}" maxlength="11" lay-verify="required" lay-reqtext="账号不能为空" placeholder="请输入账号" value="" class="layui-input">-->
<!--            &lt;!&ndash;            <tip>填写自己管理账号的名称。</tip>&ndash;&gt;-->
<!--        </div>-->
<!--    </div>-->

    <div class="layui-form-item">
        <label class="layui-form-label required">手机号</label>
        <div class="layui-input-block">
            <input type="text" name="phone" th:value="${admin.phone}" maxlength="11" lay-verify="required" lay-reqtext="手机号不能为空" placeholder="请输入手机号" value="" class="layui-input">
            <!--            <tip>填写自己管理账号的名称。</tip>-->
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">邮箱</label>
        <div class="layui-input-block">
            <input type="text" name="email" th:value="${admin.email}" maxlength="50" placeholder="请输入邮箱" class="layui-input">
            <!--            <tip>填写自己管理账号的名称。</tip>-->
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">是否冻结</label>
        <div class="layui-input-block">
            <input type="radio" name="isFreeze" value="0" title="未冻结" th:checked="${admin.isFreeze}">
            <input type="radio" name="isFreeze" value="1" title="冻结" th:checked="${admin.isFreeze}">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>

</div>
<script src="/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            //异步保存数据
            $.ajax({
                type: 'post',
                url: '/back/admin/edit',
                dataType: 'json',
                data: data.field,
                success: function (ret) {
                    if (ret.code == 0) {//编辑成功
                        layer.msg(ret.msg, function () {
                            // console.log('hello')
                            //刷新表单数据
                            parent.layui.table.reload('currentTableId')
                            // 关闭弹出层
                            var iframeIndex = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(iframeIndex);
                        })
                    } else {
                        layer.msg(ret.msg);
                    }
                }
            });
            return false;
        });

    });
</script>
</body>
</html>